home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 52
/
Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso
/
Aminet
/
misc
/
emu
/
Apex-src.lha
/
SCAN.XPL
< prev
next >
Wrap
Text File
|
2001-09-30
|
3KB
|
126 lines
\SCAN.XPL JUN-22-88 For Apex, V1.8
\This program scans for bad blocks. If it gets a read error, it will
\ reread the current sample one block at a time to determine the exact
\ block that is bad.
\REVISION HISTORY:
\JAN-85, Original
\JUN-88, Modified trap handling for Amiga
code RESERVE=3, SWAP=4, RESTART=6, CHIN=7, CHOUT=8, CRLF=9, INTIN=10,
INTOUT=11, TEXT=12, OPENI=13, TRAP=17, SPACE=18, ERRFLG=22, READ=31;
int I, J, BLOCK, UNIT, RDSIZ, BUFSIZ, DONE, SOFT, SINGLE
ENDBLK, \LAST BLOCK NUMBER OF AREA TO BE SCANNED
SAMPSIZ, \NUMBER OF 256-BYTE BLOCKS PER SAMPLE
SIZMAX, \MAX NO. OF BLOCKS IN A SAMPLE
SOFTERR, HARDERR; \COUNT OF SOFT AND HARD ERRORS
addr BUFFER;
def BEL=$07;
proc BEEP(N); \BEEP THE SPEAKER
integer N,I;
for I:=1,N do CHOUT(0,BEL);
proc ERROR(STR);
addr STR;
begin
CHOUT(0,BEL);
TEXT(0, "NOPE - ");
TEXT(0, STR);
CRLF(0);
end; \ERROR
begin \MAIN
BUFSIZ:=SPACE-200; \?? -100 DIDN'T WORK HERE, MEMORY FULL
BUFFER:=RESERVE(BUFSIZ);
TRAP(false); \WE'LL HANDLE ANY ERRORS
I:=ERRFLG; \FLUSH ANY POSSIBLE ERRORS
TEXT(0, "-- BAD BLOCK SCANNER, V1.8x2 --
");
loop begin
TEXT(0,"UNIT? "); UNIT:=INTIN(0);
if UNIT>=0 & UNIT<=7 then quit;
ERROR("BAD UNIT NUMBER");
end;
loop begin
TEXT(0,"START AND END BLOCKS? ");
BLOCK:=INTIN(0);
ENDBLK:=INTIN(0);
if ENDBLK < BLOCK then ERROR("WRONG ORDER")
else quit;
end;
ENDBLK:=ENDBLK+1; \POINT TO BLOCK AFTER THE LAST BLOCK TO TEST
SIZMAX:=SWAP(BUFSIZ) & $00FF; \(DIV BY 256, NOTE: BUFSIZ MAY BE >= $8000)
TEXT(0,"SAMPLE SIZE (1-"); INTOUT(0,SIZMAX); TEXT(0," BLOCKS)? ");
SAMPSIZ:=INTIN(0);
if SAMPSIZ<1 then SAMPSIZ:=1;
if SAMPSIZ>SIZMAX then SAMPSIZ:=SIZMAX;
CRLF(0);
RDSIZ:=SAMPSIZ;
DONE:=false;
SOFTERR:=0; HARDERR:=0;
loop begin
if BLOCK+RDSIZ > ENDBLK then
[RDSIZ:= ENDBLK-BLOCK; DONE:=true];
if RDSIZ<=0 then quit;
READ(UNIT,BLOCK,BUFFER,RDSIZ);
if ERRFLG then
begin
BEEP(1); SOFT:=true;
TEXT(0,"*** BAD BLOCK FLAGGED..."); CRLF(0);
for I:=0,RDSIZ-1 do
begin
READ(UNIT,BLOCK+I,BUFFER,1);
if ERRFLG then
[BEEP(1); TEXT(0," *** BLOCK ");
INTOUT(0,BLOCK+I);
TEXT(0," IS BAD ***"); CRLF(0);
SOFT:=false;
HARDERR:=HARDERR+1]
else [TEXT(0," BLOCK ");
INTOUT(0,BLOCK+I);
TEXT(0," IS OK"); CRLF(0)];
end;
BLOCK:=BLOCK+RDSIZ;
if SOFT then
[TEXT(0," ERROR NOT SEEN 2ND TIME THROUGH");
CRLF(0);
SOFTERR:=SOFTERR+1];
end
else begin
TEXT(0,"BLOCKS "); INTOUT(0,BLOCK);
CHOUT(0,^-);
BLOCK:=BLOCK+RDSIZ;
INTOUT(0,BLOCK-1); TEXT(0," ARE OK"); CRLF(0);
end;
if DONE then quit;
end; \loop
case of
HARDERR>0: TEXT(0,"*** BAD BLOCKS");
SOFTERR>0: TEXT(0,"SOFT ERRORS")
other TEXT(0,"NO ERRORS");
TEXT(0," WERE DETECTED"); CRLF(0);
CRLF(0);
RESTART; \(A 'LOOP' WOULD NOT REINITIALIZE ARRAY SPACE)
end; \MAIN
ERRORS");
TEXT(0," WERE DETEC